package com.wudu.gTorchat;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;

class ContactListCellRenderer extends JLabel implements ListCellRenderer<Contact> {
   private static final long serialVersionUID = 1L;

   @Override
   public Component getListCellRendererComponent(JList<? extends Contact> list, Contact contact, int cellIndex, boolean isSelected, boolean cellHasFocus) {

      if (isSelected) {
         setBackground(list.getSelectionBackground());
         setForeground(list.getSelectionForeground());
      }
      else {
         setBackground(list.getBackground());
         setForeground(list.getForeground());
      }
      
      setIcon(contact.getIcon());
      setText(contact.getName());

      return this;
   }
}